package heven.holt.library.loading.extensions

import android.view.View
import heven.holt.library.loading.LoadingStateView
import heven.holt.library.loading.ViewType

fun View.setLoadingStateCommonDecorHeader(viewDelegates: LoadingStateView.ViewDelegate<*>): LoadingStateView {
    val loadingStateView = LoadingStateView(this)
    loadingStateView.register(ViewType.TITLE, viewDelegates)
    loadingStateView.setDecorHeader(ViewType.TITLE)
    return loadingStateView
}

fun View.setLoadingStateBackWithBackgroundDecorHeader(
    decorViewDelegate: LoadingStateView.DecorViewDelegate
): LoadingStateView {
    val loadingStateView = LoadingStateView(this)
    loadingStateView.setDecorView(decorViewDelegate)
    return loadingStateView
}

fun View.bindLoadingStateView(): LoadingStateView {
    return LoadingStateView(this)
}